// Author: Domien Nowicki, Bjorn Schobben

#ifndef TEXTUREMANAGERMODEL_H
#define TEXTUREMANAGERMODEL_H

#include "TextureManager.h"
#include <QAbstractListModel>
#include <QPixmap>

class TextureManagerModel : public QAbstractListModel, public TextureManager
{
	Q_OBJECT

	public:
		TextureManagerModel(QObject *parent = 0);
		virtual ~TextureManagerModel();

		int rowCount(const QModelIndex &parent = QModelIndex()) const;
		int columnCount(const QModelIndex &parent = QModelIndex()) const;
		QVariant data(const QModelIndex &index, int role) const;
		QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;

		Qt::ItemFlags flags(const QModelIndex &index) const;


		virtual unsigned int AddTexture(const Texture& texture);
		virtual void RemoveTexture(unsigned int index);
		virtual void Clear();
		const QPixmap& GetTextureThumb(unsigned int tindex) const;

	signals:
		void modelUpdated();

	private:
		QPixmap ConvertTextureToThumb(const Texture& texture);

		std::vector<QPixmap> thumbTextures;
		QPixmap emptyTextureThumb;

		static const unsigned int THUMBSIZE = 64;
};	


#endif // TEXTUREMANAGERMODEL_H


